package com.codef.sharp.rbac.controller;

import com.codef.sharp.common.core.response.ResponseEntity;
import com.codef.sharp.rbac.entity.GroupEntity;
import com.codef.sharp.rbac.service.GroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 组信息表控制层
 *
 * @author zhanrf
 * @date 2022-02-12 20:06:41
 */
@RestController
@RequestMapping("rbac/group")
public class GroupController {
    @Autowired
    private GroupService groupService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public ResponseEntity list(@RequestParam Map<String, Object> params){
        return ResponseEntity.success();
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public ResponseEntity<GroupEntity> info(@PathVariable("id") Long id){
		GroupEntity group = groupService.getById(id);
        return ResponseEntity.success(group);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public ResponseEntity<Void> save(@RequestBody GroupEntity group){
		groupService.save(group);
        return ResponseEntity.success();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public ResponseEntity<Void> update(@RequestBody GroupEntity group){
		groupService.updateById(group);
        return ResponseEntity.success();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public ResponseEntity<Void> delete(@RequestBody Long[] ids){
		groupService.removeByIds(Arrays.asList(ids));
        return ResponseEntity.success();
    }

}
